function namespace(path, base) {
    base = (typeof(base) != 'undefined') ? base : new function(){};

    var part = path.split('.');
    var root = window;
    for(var i = 0; i < part.length; i++) {
        if(typeof(root[part[i]]) == 'undefined')
            root[part[i]] = (i < (part.length - 1)) ? new function(){} : base;
        root = root[part[i]];
    }

    return root;
}
